<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    const obj = {
        id: 1,
        name: '小刚',
        age: 44,
        gender: '男'
    }
    // 利用Object.defineProperty()方法添加或者修改对象属性
    Object.defineProperty(obj, 'school', {
        value: '理工',
        enumerable: false //默认不可枚举
    })
    Object.defineProperty(obj, 'id', {
        writable: false //不可被修改
    })
    Object.defineProperty(obj,'gender',{
        configurable:false //默认不可被删除
    })
    obj.id = 2
    console.log(obj);

    // console.log(Object.keys(obj));
    delete obj.gender
    console.log(obj);

    for (i in obj) {
        console.log(i);
    }
</script>

</html>